<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends MY_Controller {
	function __construct() {
		parent::__construct();
		$this->load->model('model_news');
	}
	
	function detail($id = '', $title = '')
	{
		$this->data['news'] = $this->model_news->get($id);
		if(empty($this->data['news'])){
			show_404();
		}
		$this->data['title'] = $this->data['news']['title'];
		$this->data['next'] = $this->model_news->get_next($id);
		$this->data['prev'] = $this->model_news->get_prev($id);
		$this->data['latest_news'] = $this->model_news->get_latest_news();
		$this->render('news/news_detail_tpl');
	}
	
	function index()
	{
		$this->data['news'] = $this->model_news->get_all();
		$this->render('news/news_index_tpl');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */